<html>
<head>
	<title>Eatversity API</title>
	<style>
	body{
		font-family:"Lucida Grande", Arial;
		font-size:14px;
	}
	
	h1{
		margin-top:70px;
	}
	
	p{
		line-height:1.6em;
	}
	
	h4{
		color:#444;
	}
	
	div.example{
		padding:0 10px;
		border:dashed 1px #ccc;
	}
	
	aside{
		width:200px;
		float:left;
		padding: 13px 0px 13px 20px;
		background-color: #F2F2F2;
		border: solid 1px #DDD;
		-webkit-border-radius: 7px;
		-moz-border-radius: 7px;
		border-radius: 7px;
		margin-top:50px;
		position:fixed;
	}
	
	section{
		float:left;
		margin-left:250px;
	}
	
	code{
		font-family: Monaco, Courier;
		background-color: #F2F2F2;
		border: solid 1px #DDD;
		padding: 1px 4px;
	}
	
	h3.method span {
		font-family: Courier, Monaco, monospace;
		background-color: #DCEDCE;
		border: solid 1px #B6DB9A;
		padding: 0px 4px;
	}
	
	table {
	width: 600px !important;
	margin: 15px 0px;
	border-collapse: collapse;
	font-size: 12px;
	line-height: 18px;
	}
	
	tr.header {
	border-width: 0px !important;
	}
	
	table th, table td {
	padding: 0;co
	border-width: 0;
	}
	
	th, td {
	border: 1px solid #DDD !important;
	padding: 5px 11px !important;
	vertical-align: top;
	text-align: left;
	}
	
	pre {
	color: #F8F8F8;
	background-color: #111;
	font-size: 12px;
	line-height: 16px;
	padding: 10px 10px;
	margin: 15px 0px;
	overflow-x: auto;
	}
	
	table code{
		background:transparent;
		padding:0;
		border:0 none;
		color:#006000;
	}
	
	</style>
	</head>
	
	<body>
		<aside>
			<ol>
				<li><a href="#overview">Overview</a></li>
				<li><a href="#user">User</a></li>
				<li><a href="#canteen">Canteen</a></li>
				<li><a href="#stall">Stall</a></li>
				<li><a href="#dish">Dish</a></li>
				<li><a href="#checkin">Checkin</a></li>
				<li><a href="#comment">Comment</a></li>
			</ol>
		</aside>
		<section>
			<a name="overview"></a>
			<h1>1. Overview</h1>	
			<p>Hi Felix and Dessy :).</p>
			<p>The design of this API is very much similar to <a href="http://developers.facebook.com/docs/reference/api/">Facebook's Graph API</a>. An object and its connections are represented in <code>/object/connection_name</code> style.</p>
			<p>For example, to get all checkins of user with ID 1 (<code>/user/1</code>), you just need to issue a request to <code>/user/1/checkins</code></p>
			
			<h3>URL structure</h2>
			<p>All API requests start with <code>http://soledroid.huytoan.com</code>, so when you see <code>/user/1</code>, it actually means <code>http://soledroid.huytoan.com/user/1</code></p>
			
			<h4>Example</h4>
			<div class="example">
			<p>Click on the links below to see the responses displayed in your web browser:<p>
			<p><code><a href="user/1/">/user/1</a></code></p>
			<p><code><a href="user/1/checkins">/user/1/checkins</a></code></p>
			</div>
			
			<h3>HTTP Methods</h3>
			<p>This API supports 3 HTTP methods:</p> 
			<p><code>GET</code> is to retrieve information. For example: issue <code>GET /user/1</code> to retrieve information about user with ID 1</p> 
			<p><code>POST</code> is to create a new object. For example: issue <code>POST /user/</code> with appropriate parameters to create a new user</p>
			<p><code>DELETE</code> is to delete an object. For example: issue <code>DELETE /user/1</code> to delete user with ID 1.</p>
			
			<h3>Response Format</h2>
			<p>JSON-encoded objects (content-type: application/json). Most of the time you'll receive an array of objects.</p>
			<h4>Example</h4>
			<pre>
[
  {
    "id":"1",
    "username":"toan",
    "fullname":"Nguyen Huy Toan",
    "image":"toan.jpg"
  }
]
			</pre>
			
			<a name="user"></a>
			<h1>2. User</h1>
			<p>The User object has the followings fields:</p>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>id</code></td>
			                <td>user id</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>username</code></td>
			                <td>username</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>fullname</code></td>
			                <td>full name</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>image</code></td>
			                <td>avatar url. This url is relative to <code>http://soledroid.huytoan.com/images/</code></td>
			                <td><code>string</code></td>
			            </tr>
			        </tbody>
			    </table>
			
			<p>The User object has the followings connections:</p>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Connection Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>checkins/</code></td>
			                <td>all checkins created by this user</td>
			                <td><code>array</code></td>
			            </tr>
						<tr>
			                <td><code>comments/</code></td>
			                <td>all comments created by this user</td>
			                <td><code>array</code></td>
			            </tr>
						<tr>
			                <td><code>friends/</code></td>
			                <td>all friends of this user</td>
			                <td><code>array</code></td>
			            </tr>
			        </tbody>
			    </table>
			
			<p>To create a new user, issue a POST request to <code>/user</code></p>
			<p>To remove an user, issue a DELETE request to <code>/user/<i>{user_id}</i></code></p>
				
			<h4>Example</h4>
			<div class="example">
			<p><code><a href="user/1/">/user/1</a></code></p>
			<p><code><a href="user/1/checkins">/user/1/checkins</a></code></p>
			<p><code><a href="user/1/comments">/user/1/comments</a></code></p>
			<p><code><a href="user/1/friends">/user/1/friends</a></code></p>
			</div>
			
			<a name="canteen"></a>
			<h1>3. Canteen</h1>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>id</code></td>
			                <td>canteen id</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>name</code></td>
			                <td>canteen name</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>image</code></td>
			                <td>canteen image</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>description</code></td>
			                <td>description</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>latitude</code></td>
			                <td>latitude</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>longitude</code></td>
			                <td>longitude</td>
			                <td><code>string</code></td>
			            </tr>
			        </tbody>
			    </table>
				<p>The Canteen object has the followings connections:</p>
				<table>
				        <tbody>
				            <tr class="header">
				                <th>Connection Name</th>
				                <th>Description</th>
				                <th>Return</th>
				            </tr>
				            <tr>
				                <td><code>stalls/</code></td>
				                <td>all stalls in this canteen</td>
				                <td><code>array</code></td>
				            </tr>
							<tr>
				                <td><code>comments/</code></td>
				                <td>all comments made about this canteen</td>
				                <td><code>array</code></td>
				            </tr>
				        </tbody>
				    </table>

				<p>Creating and removing Canteen is not supported via API. Do this by directly editing database if you really need to.</p>
			<h4>Example</h4>
			<div class="example">
			<p><code><a href="canteen/1/">/canteen/1</a></code></p>
			<p><code><a href="canteen/1/stalls">/canteen/1/stalls</a></code></p>
			<p><code><a href="canteen/1/comments">/canteen/1/comments</a></code></p>
			</div>
			
			<a name="stall"></a>
			<h1>4. Stall</h1>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>id</code></td>
			                <td>stall id</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>name</code></td>
			                <td>stall name</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>image</code></td>
			                <td>stall image</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>description</code></td>
			                <td>description</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>canteen_id</code></td>
			                <td>canteen to which this stall belongs</td>
			                <td><code>int</code></td>
			            </tr>
			        </tbody>
			    </table>
				<p>The Stall object has the followings connections:</p>
				<table>
				        <tbody>
				            <tr class="header">
				                <th>Connection Name</th>
				                <th>Description</th>
				                <th>Return</th>
				            </tr>
				            <tr>
				                <td><code>dishes/</code></td>
				                <td>all dishes offered by this stall</td>
				                <td><code>array</code></td>
				            </tr>
							<tr>
				                <td><code>checkins/</code></td>
				                <td>all checkins in this canteen</td>
				                <td><code>array</code></td>
				            </tr>
							<tr>
				                <td><code>comments/</code></td>
				                <td>all comments made about this canteen</td>
				                <td><code>array</code></td>
				            </tr>
							<tr>
				                <td><code>offers/</code></td>
				                <td>all offers from this stall</td>
				                <td><code>array</code></td>
				            </tr>
				        </tbody>
				    </table>

				<p>Creating and removing Stall is not supported via API. Do this by directly editing database if you really need to.</p>
			<h4>Example</h4>
			<div class="example">
			<p><code><a href="stall/3/">/stall/3</a></code></p>
			<p><code><a href="stall/3/dishes">/stall/3/dishes</a></code></p>
			<p><code><a href="stall/3/checkins">/stall/3/checkins</a></code></p>
			<p><code><a href="stall/3/comments">/stall/3/comments</a></code></p>
			<p><code><a href="stall/3/offers">/stall/3/offers</a></code></p>
			</div>
			
			<a name="dish"></a>
			<h1>5. Dish</h1>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>id</code></td>
			                <td>dish id</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>name</code></td>
			                <td>dish name</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>image</code></td>
			                <td>dish image</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>description</code></td>
			                <td>description</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>price</code></td>
			                <td>dish price</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>stall_id</code></td>
			                <td>stall that sells this dish</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>on_promotion</code></td>
			                <td>indicate whether this dish is being discounted (will appears in Offers tab). <code>0</code> means NO, <code>1</code> means YES</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>rating</code></td>
			                <td>dish rating, ranging from 1 to 5. Initial dish rating is 0.</td>
			                <td><code>float</code></td>
			            </tr>
			        </tbody>
			    </table>
			
				<p>The Dish object has the followings connections:</p>
				<table>
				        <tbody>
				            <tr class="header">
				                <th>Connection Name</th>
				                <th>Description</th>
				                <th>Return</th>
				            </tr>
							<tr>
				                <td><code>comments/</code></td>
				                <td>all comments made about this dish</td>
				                <td><code>array</code></td>
				            </tr>
				        </tbody>
				    </table>
				
				<p>Creating and removing Dish is not supported via API. Do this by directly editing database if you really need to.</p>
			<h4>Example</h4>
			<div class="example">
			<p><code><a href="dish/3/">/dish/3</a></code></p>
			<p><code><a href="dish/3/comments">/dish/3/comments</a></code></p>
			</div>


			<a name="checkin"></a>
			<h1>6. Checkin</h1>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>id</code></td>
			                <td>checkin id</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>user_id</code></td>
			                <td>id of the user who checkins</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>stall_id</code></td>
			                <td>id of the stall checked in</td>
			                <td><code>int</code></td>
			            </tr>
						
			        </tbody>
			    </table>
			
				<p>To create a new checkin, issue a POST request to <code>/checkin</code></p>
				<p>To remove a checkin, issue a DELETE request to <code>/checkin/<i>{checkin_id}</i></code></p>
			<h4>Example</h4>
			<div class="example">
			<p><code><a href="checkin/3/">/checkin/3</a></code></p>
			</div>
			
			<a name="comment"></a>
			<h1>7. Comment</h1>
			<table>
			        <tbody>
			            <tr class="header">
			                <th>Name</th>
			                <th>Description</th>
			                <th>Return</th>
			            </tr>
			            <tr>
			                <td><code>id</code></td>
			                <td>comment id</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>type</code></td>
			                <td>type of the comment. <code>0</code> means comment made about a canteen. <code>1</code> means comment made about a stall. <code>2</code> means comment made about a dish. </td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>comment</code></td>
			                <td>content of the comment</td>
			                <td><code>string</code></td>
			            </tr>
						<tr>
			                <td><code>rating</code></td>
			                <td>rating</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>user_id</code></td>
			                <td>id of the user who made this comment</td>
			                <td><code>int</code></td>
			            </tr>
						<tr>
			                <td><code>to_id</code></td>
			                <td>id of the canteen/stall/dish about which this comment is made</td>
			                <td><code>int</code></td>
			            </tr>
			        </tbody>
			    </table>
			
				<p>To create a new comment, issue a POST request to <code>/comment</code></p>
				<p>To remove a comment, issue a DELETE request to <code>/comment/<i>{comment_id}</i></code></p>
			<h4>Example</h4>
			<div class="example">
			<p><code><a href="comment/3/">/comment/3</a></code></p>
			</div>
		</section>
	</body>
</html>